﻿<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>商品后台管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />

    <link rel="stylesheet" href="./css/all.css">
    <link rel="stylesheet" href="./css/bootstrap.css">
    <link rel="stylesheet" href="./css/course_category.css">

    <style>
        .red{
            color: red;
        }
    </style>

</head>

<body>
    <div id="app">

        <nav class="navbar">
            <div class="container" style="height: 80px;background: #58a3f9">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">
                        <img src="image/easy-pay.png">
                    </a>
                </div>
                <ul class="nav navbar-nav navbar-right" style="margin-top: 30px">
                    <li><a href="#"><span class="inner">首页</span></a></li>
                    <li>
                        <a href="#">
                            <span class="inner">商品管理</span></a>
                    </li>
                    <li>
                        <a href="#">
                            <span class="inner">购物车管理</span>
                        </a>
                    </li>

                    <li>
                        <a href="#">
                            <span class="inner">用户管理</span></a>
                    </li>
                </ul>
            </div>
        </nav>
        <div style="min-height: 400px">
            <div class="container">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4>商品管理-增加商品</h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal">
                            <!-- 在此处添加并修改结构代码，参考以下注释文档 -->


                            <div class="form-group">
                                <label for="title" class="col-sm-3 control-label">商品标题</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" id="title" placeholder="在此输入商品标题" v-model="good.title" value="">
                                </div>
                                <div class="col-sm-1 red">*</div>
                            </div>
                            <div class="form-group">
                                <label for="title" class="col-sm-3 control-label">商品描述</label>
                                <div class="col-sm-8">
                                    <!-- <input type="text" class="form-control" id="title" placeholder="在此输入商品标题" value=""> -->
                                    <textarea class="form-control" id="inputContent" cols="30" style="resize: none;"
                                        placeholder="在此輸入商品描述" rows="3" v-model="good.content"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="title" class="col-sm-3 control-label">圖片路徑</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" id="title" placeholder="在此输入商品圖片路徑"
                                        value="" v-model="good.imagePath">
                                </div>
                                <div class="col-sm-1 red">*</div>
                            </div>
                            <div class="form-group">
                                <label for="title" class="col-sm-3 control-label">商品價格</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" id="title" placeholder="在此输入商品價格" value="" v-model="good.price">
                                </div>
                                <div class="col-sm-1 red">*</div>
                            </div>


                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <p class="form-control-static text-danger">{{msg}}</p>
                                </div>
                            </div>
                            <div style="text-align: right">
                                <button type="button" class="btn btn-primary" id="assure" @click="addGoods">确定</button>
                                <button type="button" class="btn btn-default">取消</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <footer>
            <div class="container">
                <p class="text-center">易购集团</p>
                <p class="text-center">Copyright 2019</p>
            </div>
        </footer>

    </div>

</body>

</html>
<script src="./js/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            good:{
                title:"",
                content:"",
                imagePath:"",
                price:""
            },
            msg:"在此顯示信息（錯誤或者成功）"
        },
        methods:{
            addGoods(){
                console.log("點擊了");
                axios.post('http://127.0.0.1:8080/h4/goods/addGoods',this.good)
                .then(res=>{
                    console.log(res);
                    if(res.status==200&&res.data.success){
                        console.log(res.data.msg);
                        this.msg = res.data.msg
                    }
                })
                .catch(err=>{
                    console.log(err);
                })

            }
        }
    })
</script>